import request from 'src/axios'

/**
 * @description 分页查询账户
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const pageAccount = (params: object) => {
  return request.get('/system/account/page', { params })
}

/**
 * @description 查看账户信息
 * @param { String } id 主键
 * @returns Promise
 */
export const viewAccount = (id: string) => {
  return request.get('/system/account', { params: { id } })
}

/**
 * @description 新增账户
 * @param { Object } data 新增数据
 * @returns Promise
 */
export const saveAccount = (data: object) => {
  return request.post('/system/account', data)
}

/**
 * @description 修改账户
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateAccount = (data: object) => {
  return request.put('/system/account', data)
}

/**
 * @description 删除账户
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const deleteAccount = (ids: Array<string>) => {
  return request.delete('/system/account', { data: ids })
}

/**
 * @description 启用账户
 * @param { String } id 主键
 * @returns Promise
 */
export const enableAccount = (id: string) => {
  return request.put('/system/account/enable', { id })
}

/**
 * @description 禁用账户
 * @param { String } id 主键
 * @returns Promise
 */
export const disableAccount = (id: string) => {
  return request.put('/system/account/disable', { id })
}

/**
 * @description 重置密码
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const resetPassword = (ids: Array<string>) => {
  return request.put('/system/account/reset/password', ids)
}

/**
 * @description 查询用户授权角色
 * @param { String } id 主键
 * @returns Promise
 */
export const listCheckedRole = (id: string) => {
  return request.get('/system/account/role', { params: { id } })
}

/**
 * @description 授权角色
 * @param { Object } data 授权数据
 * @returns Promise
 */
export const grantRole = (data: object) => {
  return request.post('/system/account/grant', data)
}

/**
 * @description 查看当前登录用户
 * @returns Promise
 */
export const viewCurrent = () => {
  return request.get('/system/account/current')
}

/**
 * @description 修改当前登录用户
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateCurrent = (data: object) => {
  return request.put('/system/account/current/profile', data)
}

/**
 * @description 修改当前用户密码
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateCurrentPassword = (data: object) => {
  return request.put('/system/account/current/password', data)
}
